package com.yangye.picommon.utils;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.yangye.picommon.model.PiResult;
import org.springframework.http.MediaType;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author yangye
 * @date 2019/8/20
 */
public class RespUtil {

	private static ObjectMapper objectMapper = new ObjectMapper();

	public static void writeJson(HttpServletResponse response, PiResult result) throws IOException {
		response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
		objectMapper.writeValue(response.getWriter(), result);
	}
}
